#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include<iostream> 
using namespace std;
typedef struct node{
   int data;
   struct node *next;
}ListNode;
typedef ListNode *List;
void CreateList(List &L,int n);
void ReverseList(List &L);
void PrintList(List L);

int main()
{
       int n;
      List L;
      cin>>n;
     CreateList(L,n);
   //  PrintList(L);
     ReverseList(L);
    PrintList(L);

 } 
void CreateList(List &L,int n)
{
	List p,tail;
	L=new ListNode;
	L->next=NULL;
	tail=L;
	int num;
	while(n--){
		cin>>num;
		p=new ListNode;
		p->data=num;
		p->next=NULL;
		tail->next=p;
		tail=p;
	}
} 
void ReverseList(List &L)
{
	List p=L->next,q;
	L->next=NULL;
	while(p){
		q=p;
		p=p->next;
		q->next=L->next;
		L->next=q;
	}
} 
void PrintList(List L)
{
	List l=L->next;
	if(L->next==NULL)cout<<"NULL"<<endl;
	while(l){
		cout<<l->data;
		if(l->next!=NULL)cout<<' ';
		l=l->next;
	}
	cout<<endl;
} 
